package com.bdqn.service.impl;

import com.bdqn.entity.Setmeal;
import com.bdqn.mapper.SetmealMapper;
import com.bdqn.param.response.DishDto;
import com.bdqn.param.response.Page;
import com.bdqn.service.SetmealService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 套餐 服务实现类
 * </p>
 *
 * @author hunter
 * @since 2022-06-11
 */
@Service
public class SetmealServiceImpl extends ServiceImpl<SetmealMapper, Setmeal> implements SetmealService {
    @Autowired
    private SetmealMapper setmealMapper;

    @Override
    public Page<Setmeal> pageInfo(Integer page, Integer pageSize, String name) {
        PageHelper.startPage(page,pageSize);
        List<Setmeal> setmealList=setmealMapper.selectListByName(name);
        PageInfo<Setmeal> pageInfo=new PageInfo(setmealList);
        //封装分页对象
        return new Page<Setmeal>(pageInfo.getPageNum(),pageInfo.getPageSize(),pageInfo.getTotal(),pageInfo.getList());
    }

    /**
     * 通过套餐的分类id查询该套餐id下启动状态的套餐列表
     * @param categoryId
     * @param status
     * @return
     */
    @Override
    public List<Setmeal> selectByCategoryId(Long categoryId, Integer status) {
        return setmealMapper.selectByCategoryId(categoryId,status);
    }
}
